﻿﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>字典目录管理</title>
    <#include "../common/link.ftl">
    <script>
        $(function () {

           $('.btn-input') .click(function() {
               console.log(this);
               //得到的数据就是js对象
               var data = $(this).data('json');
               //清除数据
               $('#editForm')[0].reset();
               if(data){
                   //设置值
                   $('input[name="title"]').val(data.title);
                   $('input[name="id"]').val(data.id);
                   $('input[name="name"]').val(data.name);
                   $('input[name="age"]').val(data.age);
                   $('input[name="tel"]').val(data.tel);
                   $('input[name="qq"]').val(data.qq);
                   $('select[name="job.id"]').val(data.jobId);
                   $('select[name="source.id"]').val(data.sourceId);
                   $('select[name="seller.id"]').val(data.sellerId);
               }
               //显示模态框
               $('#editModal').modal('show');

           });

           $('.btn-submit').click(function () {
               // 使用 AJAX 异步提交
               $('#editForm').ajaxSubmit(function (data) {
                  // console.log(1);
                   if(data.success){
                        $.messager.confirm('温馨提示',data.msg, function () {
                           //window.location.reload();
                           location.href='/customer/poolList.do'
                       });
                    }else{
                        $.messager.alert('温馨提示',data.msg);
                    }
               });
           })
           $('.input-submityy').click(function () {
               // 使用 AJAX 异步提交
               $('#editForm').ajaxSubmit(function (data) {
                  // console.log(1);
                   if(data.success){
                        $.messager.confirm('温馨提示',data.msg, function () {
                           //window.location.reload();
                           location.href='/customer/poolList.do'
                       });
                    }else{
                        $.messager.alert('温馨提示',data.msg);
                    }
               });
           })
        });
    </script>
</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">
    <#include "../common/navbar.ftl">
    <!--菜单回显-->
    <#--<c:set var="currentMenu" value="customer"/>-->
    <#assign currentMenu = "customer_pool">
    <#--<%@include file="/WEB-INF/views/common/menu.jsp"%>-->
    <#include "../common/menu.ftl">
    <div class="content-wrapper">
        <section class="content-header">
            <h1>潜在客户</h1>
        </section>
        <script>
            $(function () {
                $('.btn-selectff').click(function () {
                    $('#searchForm').submit();
                });

            });
        </script>
        <section class="content">
            <div class="box">
                <!--高级查询--->
                <form class="form-inline" id="searchForm" action="#" method="post">
                    <input type="hidden" name="currentPage" id="currentPage" value="1">
                    <input type="text" class="form-control" name="keyname" value="${(qo.keyname)!}"  placeholder="请输入姓名或者电话">
                    <@shiro.hasAnyRoles name="admin,Market_Manager">
                        <select class="form-control" id="" name="sellerId" readonly>
                            <option value="-1">全部</option>
                            <#list sellers as seller>
                                <option value="${(seller.id)!}" <#if qo.sellerId?? && qo.sellerId == seller.id >selected</#if>>${(seller.name)!}</option>
                            </#list>
                        </select>
                    </@shiro.hasAnyRoles>
                    <button type="button" class="btn btn-primary btn-selectff">查询</button>
                 <@shiro.hasPermission name="customer:saveOrUpdate">
                    <a class="btn btn-success btn-input" style="margin: 10px">
                        <span class="glyphicon glyphicon-plus"></span> 添加
                    </a>
                </@shiro.hasPermission>
                </form>
                <!--编写内容-->
                <div class="box-body table-responsive no-padding ">
                    <table class="table table-hover table-bordered">
                        <tr>
                            <th>编号</th>
                            <th>姓名</th>
                            <th>年龄</th>
                            <th>性别</th>
                            <th>电话</th>
                            <th>qq</th>
                            <th>职业</th>
                            <th>来源</th>
                            <th>负责人</th>
                            <th>录入员</th>
                            <th>状态</th>
                            <th>录入时间</th>
                            <th>操作</th>
                        </tr>
                        <#list pageInfo.list as customer >
                            <tr>
                                <td>${customer_index +1}</td>
                                <td>${customer.name}</td>
                                <td>${customer.age}</td>
                                <td>${customer.genderName}</td>
                                <td>${customer.tel}</td>
                                <td>${customer.qq}</td>
                                <td>${customer.job.title}</td>
                                <td>${customer.source.title}</td>
                                <td>${customer.seller.name}</td>
                                <td>${(customer.inputUser.name)!}</td>
                                <td>${customer.statusName}</td>
                                <td>${customer.inputTime?string("yyyy-MM-dd")}</td>
                                <td>
                                    <@shiro.hasPermission name="customer:saveOrUpdate">
                                        <a data-json='${customer.jsonData}' class="btn btn-info btn-xs btn-input">
                                            <span class="glyphicon glyphicon-pencil"></span> 编辑
                                        </a>
                                    </@shiro.hasPermission>
                                </td>
                            </tr>
                        </#list>

                    </table>
                    <!--分页-->
                <#include "../common/page.ftl">
                </div>
            </div>
        </section>
    </div>
    <#include "../common/footer.ftl">
</div>
<#--客户编辑模态框-->
<div class="modal fade" id="editModal">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title inputTitle">客户编辑</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" action="/customer/saveOrUpdate.do" method="post" id="editForm">
                    <input type="hidden" value="" name="id">
                    <div class="form-group" >
                        <label  class="col-sm-3 control-label">客户名称：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" name="name"
                                   placeholder="请输入客户姓名"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label  class="col-sm-3 control-label">客户年龄：</label>
                        <div class="col-sm-6">
                            <input type="number" class="form-control" name="age"
                                   placeholder="请输入客户年龄"/>
                        </div>
                    </div>
                    <div class="form-group" >
                        <label  class="col-sm-3 control-label">客户性别：</label>
                        <div class="col-sm-6">
                            <select class="form-control" name="gender">
                                <option value="1">男</option>
                                <option value="0">女</option>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label  class="col-sm-3 control-label">客户电话：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" name="tel"
                                   placeholder="请输入客户电话"/>
                        </div>
                    </div>
                    <div class="form-group" >
                        <label  class="col-sm-3 control-label">客户QQ：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" name="qq"
                                   placeholder="请输入客户QQ"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label  class="col-sm-3 control-label">客户工作：</label>
                        <div class="col-sm-6">
                            <select class="form-control" name="job.id">
                            <#list jobs as j>
                                <option value="${j.id}">${j.title}</option>
                            </#list>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label  class="col-sm-3 control-label">客户来源：</label>
                        <div class="col-sm-6">
                            <select class="form-control" name="source.id">
                            <#list sources as s>
                                <option value="${s.id}">${s.title}</option>
                            </#list>
                            </select>
                        </div>
                    </div>

                    <div class="form-group">
                        <label  class="col-sm-3 control-label">销售人员：</label>
                        <div class="col-sm-6">
                            <select class="form-control" name="seller.id">
                            <#list sellers as e>
                                <option value="${e.id}">${e.name}</option>
                            </#list>
                            </select>
                        </div>
                    </div>

                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary input-submityy" >保存</button>
                <button type="button" class="btn btn-default" data-dismiss="modal" >取消</button>
            </div>
        </div>
    </div>
</div>
</body>
</html>
